<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="自定义时间段" label-width="100px" prop="quesUserNumber">
        <el-date-picker
          v-model="dateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="账号类别" prop="quesType">
        <el-select style="width: 100%" v-model="queryParams.quesType" placeholder="请选择">
          <el-option v-for="dict in typeOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="工号/学号" label-width="80px" prop="quesId">
        <el-input v-model="queryParams.quesId" placeholder="请输入工号/学号" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="手机号" prop="quesTitle">
        <el-input v-model="queryParams.quesTitle" placeholder="请输入手机号" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="姓名" prop="quesDescribe">
        <el-input v-model="queryParams.quesDescribe" placeholder="请输入姓名" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="tableList">
      <el-table-column label="工号/学号" align="center" prop="quesId" />
      <el-table-column label="创建时间" align="center" prop="quesUserNumber" />
      <el-table-column label="姓名" align="center" prop="quesUserName" />
      <el-table-column label="电话" align="center" prop="quesTitle" />
      <el-table-column label="身份证" align="center" prop="quesDescribe" />
      <el-table-column label="角色" align="center" prop="quesDescribe" />
      <el-table-column label="用户组" align="center" prop="quesDescribe" />
      <el-table-column label="类别" align="center" prop="quesDescribe" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button type="text" icon="el-icon-document" @click="handleOpenDetails(scope.row)" v-hasPermi="['audit:account:details']">查看详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
    <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
      <el-card class="details-view" shadow="never" body-style="padding: 0">
        <el-row class="details-item" v-for="data in detailsData">
          <el-col class="details-label" :span="6">{{data.name}}</el-col>
          <el-col class="details-value" :span="18">{{data.value}}</el-col>
        </el-row>
      </el-card>
    </el-dialog>
  </div>
</template>

<script>
import { listFeedback } from '@/api/problem/feedback';
import { getAccount } from '@/pages/views/account/manage/service';
const defaultDetailsData =  [
    { name: '账号/工号', value: '' },
    { name: '姓名', value: '' },
    { name: '电话', value: '' },
    { name: '身份证', value: '' },
    { name: '角色', value: '' },
    { name: '状态', value: '' },
    { name: '用户组', value: '' },
    { name: '部门', value: '' },
    { name: '岗位', value: '' },
  ]
export default {
  name: 'AuditAccount',
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      typeOptions: [
		  {
			  dictValue:'1',
			  dictLabel:'全部类型'
			  
		  },
		  {
		  			  dictValue:'2',
		  			  dictLabel:'休眠账号'
		  			  
		  },
		  {
		  			  dictValue:'3',
		  			  dictLabel:'孤儿账号'
		  			  
		  },
		  {
		  			  dictValue:'4',
		  			  dictLabel:'密码强度低'
		  			  
		  },
		  {
		  			  dictValue:'5',
		  			  dictLabel:'不规范的账号'
		  			  
		  },
		  {
		  			  dictValue:'6',
		  			  dictLabel:'恶意认证'
		  			  
		  },
		  {
		  			  dictValue:'7',
		  			  dictLabel:'密码暴力猜解'
		  			  
		  },
		  {
		  			  dictValue:'8',
		  			  dictLabel:'无阻账号'
		  			  
		  },
	  ],
      dateRange: [],
      // 弹出层标题
      title: '账号详情',
      // 是否显示弹出层
      open: false,
      // 选中行id
      currentRow: {},
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      tableList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      detailsData: [...defaultDetailsData],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      listFeedback(this.queryParams)
        .then((response) => {
          this.tableList = response.rows;
          this.total = response.total;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 表单重置
    reset() {
      this.form = {
        quesId: null,
        quesUserNumber: null,
        quesUserName: null,
        quesTitle: null,
        quesDescribe: null,
        createTime: null,
      };
      this.resetForm('form');
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm');
      this.handleQuery();
    },
    /** 查看详情操作 */
    handleOpenDetails(row) {
      this.open = true;
      const userId = row.userId;
      getAccount(userId).then((response) => {});
    },
  },
};
</script>

<style lang="scss" type="text/scss">
  .details-view{
    margin: -12px 20px 20px;
    .details-item {
      line-height: 50px;
      border-bottom: 1px solid rgb(230, 235, 245);
      &:last-child{
        border-bottom: none;
      }
    }
    .details-label{
      text-align: center;
      background-color: rgb(248, 248, 249);
      border-right: 1px solid rgb(230, 235, 245);
    }
    .details-value{
      padding: 0 20px;
    }
  }
</style>
